using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Threading;

namespace GoogleNet
{
    /// <summary>
    /// Specifies how the name of a Feature is drawn in the 3D viewer. 
    /// A custom color, color mode, and scale for the label (name) can be specified. 
    /// </summary>
    public class KmlLabelStyle : KmlColorStyle
    {
        private string tagName = "LabelStyle";

        #region Scale
        private double scale = 1;

        /// <summary>
        /// Resizes the label (default=1). 
        /// </summary>
        /// <value>The scale.</value>
        public double Scale
        {
            get { return scale; }
            set { scale = value; }
        }
        #endregion

        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public override string TagName
        {
            get { return tagName; }
        }

        #endregion

        #region IKmlGenerator Members

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public override void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);
            base.GenerateKml(writer);

            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
            if(scale != 1)
                writer.WriteElementString("scale", scale.ToString(Thread.CurrentThread.CurrentCulture.NumberFormat));
            Thread.CurrentThread.CurrentCulture = currentCulture;

            writer.WriteEndElement();
        }

        #endregion
    }
}
